<template>
	<view class="container">
		<view class="body">
			<view class="content">
				<uni-forms ref="form" :modelValue="formData" :rules="rules">
					<uni-forms-item label="姓名" name="name">
						<uni-easyinput :inputBorder="false" type="text" v-model="formData.name" placeholder="请输入姓名" />
					</uni-forms-item>
					<view class="text_forms">
						<text>证件类型</text>
						<view class="">
							身份证
							<uni-icons type="right" size="16" color="gray"></uni-icons>

						</view>
					</view>
					<uni-forms-item label="身份证号" name="name">
						<uni-easyinput :inputBorder="false" type="text" v-model="formData.code" placeholder="请输入姓名" />
					</uni-forms-item>
					<uni-forms-item label="手机号" name="name">
						<uni-easyinput :inputBorder="false" type="text" v-model="formData.phone" placeholder="请输入姓名" />
					</uni-forms-item>
					<view class="text_forms">
						<text>设置默认联系人</text>
						<!-- 1是默认 2是普通 -->
						<switch color="orangered" :checked="formData.check==1" :value="formData.check"
							style="transform:scale(0.7)" />
					</view>

				</uni-forms>
			</view>
		</view>
		<view class="footer">
			<view class="btn" @click="aubiSubmit">
				确定
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive
	} from 'vue';
	import {
		onShow
	} from "@dcloudio/uni-app"
	import {
		addMemInfo
	} from "@/api/user.js"


	const formData = reactive({
		check: '2',
		name: '',
		phone: '',
		code: ''
	})
	// 点击去常用访客
	function toAdduser() {
		uni.navigateTo({
			url: '/pagesD/addcontacts/addcontacts'
		})
	}
	// 点击确定
	function aubiSubmit() {
		console.log(formData)
		addMemInfo({
			name: formData.name,
			tel: formData.phone,
			idcard: formData.code,
			isdefault: formData.check
		}).then(res => {

		})
	}
</script>

<style lang="less" scoped>
	.container {
		display: flex;
		flex-direction: column;

		.body {
			flex: 1;

			.content {
				margin-top: 30rpx;
				background: #fff;
				padding: 30rpx;
				box-sizing: border-box;

				.uni-forms-item {
					display: flex;
					align-items: center;
					flex-direction: unset;
					border-bottom: 1rpx solid #efefef;
					margin: 0;
					padding: 10rpx 0;

				}

				.uni-forms-item__label {
					padding: 0 !important;
				}

				.text_forms {
					display: flex;
					align-items: center;
					justify-content: space-between;
					color: #606266;
					font-size: 30rpx;
					border-bottom: 1rpx solid #efefef;
					margin: 0;
					padding: 20rpx 0;

					text {
						font-size: 28rpx;
					}
				}
			}
		}

		.footer {
			width: 90%;
			margin-left: 5%;
			height: 120rpx;
			padding-bottom: 20rpx;
			box-sizing: border-box;

			.btn {
				background: orangered;
				color: #fff;
				line-height: 100rpx;
				text-align: center;
				border-radius: 100rpx;
			}
		}
	}
</style>